package com.xq.spring.javacfg;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import com.xq.spring.beans.Chinese;
import com.xq.spring.beans.Person;
import com.xq.spring.container.ContainerEvent;

/**
 * 测试AnnotationConfigApplicationContext容器.
 * 
 * @author 郭凯强
 */
public class AnnotationConfigBF {
	public static void main(String[] args) {
		ApplicationContext ctx = new AnnotationConfigApplicationContext(
				BeanConfig.class);
		// 让Bean获取Spring容器,并执行其中的方法
		// Person person = ctx.getBean("chinese",Chinese.class); //@Bean方法使用了 @Lazy(true)时使用
		Person person = ctx.getBean(Chinese.class);
		person.useAxe();
		ContainerEvent event=new ContainerEvent(ctx, "ANNOTATION-TEST");
		ctx.publishEvent(event);
	}
}
